﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema 
    targetNamespace="http://wscf/Common/MessageHeaders/v1"
    elementFormDefault="qualified"
    xmlns="http://wscf/Common/MessageHeaders/v1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xs:element name="RequestHeader" type="RequestHeaderType" nillable="true" />
	<xs:element name="ResponseHeader" type="ResponseHeaderType" nillable="true" />
	
	<xs:complexType name="RequestHeaderType">
		<xs:sequence>
			<xs:element name="UnitOfWork" type="UnitOfWorkType" minOccurs="0" />
			<xs:element name="Origin" type="OriginType" minOccurs="0" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ResponseHeaderType">
		<xs:sequence>
			<xs:element name="UnitOfWork" type="UnitOfWorkType" minOccurs="0" />
			<xs:element name="TimeStamp" type="xs:dateTime" minOccurs="0" />
			<xs:element name="ReturnCode" type="ReturnCodeType" minOccurs="1" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="UnitOfWorkType">
		<xs:sequence>
			<xs:element name="ID" minOccurs="0" >
				<xs:annotation>
					<xs:documentation>ID used to track a unit of work through call stack betwenn multiple services.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA­F]{12}" />
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
			<xs:element name="MessageID" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Message ID of individual service calls.</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA­F]{12}" />
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="OriginType">
		<xs:sequence>
			<xs:element name="Username" type="xs:string" minOccurs="0" />
			<xs:element name="Service" type="xs:string" minOccurs="0" />
			<xs:element name="Operation" type="xs:string" minOccurs="0" />
			<xs:element name="Location" type="xs:string" minOccurs="0" />
			<xs:element name="IpAddress" type="xs:string" minOccurs="0" />
			<xs:element name="TimeStamp" type="xs:dateTime" minOccurs="0" />
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ReturnCodeType">
		<xs:sequence>
			<xs:element name="Severity" type="Severity" minOccurs="1" />
			<xs:element name="Code" type="xs:int" minOccurs="1">
				<xs:annotation>
					<xs:documentation>Return code, 0 means success.</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="Description" type="xs:string" minOccurs="0" />
		</xs:sequence>
	</xs:complexType>

	<xs:simpleType name="Severity">
		<xs:annotation>
			<xs:documentation>Call state severity level.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:enumeration value="SUCCESS" />
			<xs:enumeration value="ERROR" />
			<xs:enumeration value="WARNING" />
			<xs:enumeration value="INFORMATION" />
		</xs:restriction>
	</xs:simpleType>

</xs:schema>